<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* Name:  Human resource pro
*
* Author: Lucky Sharma
*         jumboteam726@gmail.com
*
* Website: http://www.jumboteam.net
*
* Created:  03.25.2014
*/

class admin_booking_model extends CI_Model {

    /**
     * Limit
     *
     * @var string
     * */
    public $_ion_limit = NULL;

    /**
     * Offset
     *
     * @var string
     * */
    public $_ion_offset = NULL;

    /**
     * message (uses lang file)
     *
     * @var string
     * */
    protected $messages;

    /**
     * error message (uses lang file)
     *
     * @var string
     * */
    protected $errors;

    /**
     * error start delimiter
     *
     * @var string
     * */
    protected $error_start_delimiter;

    /**
     * error end delimiter
     *
     * @var string
     * */
    protected $error_end_delimiter;

    function __construct() {
        parent::__construct();
        $this->load->database();
        $this->lang->load('admin_estate');
        $this->load->helper('date');

        //Load the session, CI2 as a library, CI3 uses it as a driver
        if (substr(CI_VERSION, 0, 1) == '2') {
            $this->load->library('session');
        } else {
            $this->load->driver('session');
        }

        //initialize messages and error
        $this->messages = array();
        $this->errors = array();
        $this->message_start_delimiter = "<p>";
        $this->message_end_delimiter = "</p>";
        $this->error_start_delimiter = "<p>";
        $this->error_end_delimiter = "</p>";
    }

    public function num_row_user($whr = NULL) {
        if ($whr != NULL) {
            $this->db->where($whr);
        } else {
            $this->db->where('publish', 1);
        }
        return $this->db->get('estate')->num_rows();
    }

    public function num_row_selectbox() {
        return $this->db->get('selectbox')->num_rows();
    }

    public function num_row_getName($table_name, $where = NULL) {
        if ($where != NULL) {
            $this->db->where($where);
        }
        return $this->db->get($table_name)->num_rows();
    }

    public function num_row_category() {
        return $this->db->get('category')->num_rows();
    }

    public function num_row_type() {
        return $this->db->get('estatetype')->num_rows();
    }

    public function groupListArray($id = NULL) {
    	 $this->db->select('*');
         $this->db->from('hrmgroups');
		 $query = $this->db->get()->result();
        return $query;
    }
		
	public function customerListArray($id = NULL) {
    	$this->db->select('*');
        $this->db->from('customers');
		$query = $this->db->get()->result();
        return $query;
    }

	
	// Booking reservation
	public function bookingReservation($data) {
        $query = $this->db->insert('booking', $data);
        //$this->set_message('hrm_staff_success');
        return true;
    }
	
	public function reservationAvailability($data) {
        $query = $this->db->insert('reservation_availability', $data);
        //$this->set_message('hrm_staff_success');
        return true;
    }
	public function bookingAvailability($id = NULL) {
        if ($id != NULL) {
           
			$this->db->select('*');
            $this->db->from('booking');
            $query = $this->db->where('booking.customerid', $id)->get()->result();
	    }else
		{
		$this->db->select('*');
           $query =  $this->db->from('booking')->get()->result();
           // $query = $this->db->where('booking.customerid', $id)->get()->result();
		
		}
        
        return $query;
	
	}
	public function setStatus($status = 1,$id = null) {
        if ($id != NULL) {
    		$this->db->select('*');
            $this->db->from('booking');
            $query = $this->db->where('booking.customerid', $id)->get()->result();
	        return true;
        } else {
            return false;
        }
    }
    
	
}